package PTA.javaA;

import java.util.Scanner;


class ArrayUtil{
    public static double findMax(double[] arr,int begin, int end)throws IllegalArgumentException{
        if (!(begin<end)) {
            throw new IllegalArgumentException("begin:"+begin+" >= end:"+end);
        } else if (!(begin>=0)) {
            throw new IllegalArgumentException("begin:"+begin+" < 0");
        } else if (!(end<=arr.length)) {
            throw new IllegalArgumentException("end:"+end+" > arr.length");
        }
        double max=0;
        for(int i=begin;i<end;i++){
            max=Math.max(arr[i],max);
        }
        return max;
    }
}



public class ex32 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);


      int n = sc.nextInt();
      double []arr = new double[n];
       // ArrayUtil a = new ArrayUtil();
      for(int i=0;i<n;i++){
          arr[i]=sc.nextDouble();
      }

     while(sc.hasNextDouble()){
         try{
             System.out.println(ArrayUtil.findMax(arr,sc.nextInt(),sc.nextInt()));

         }catch(Exception e){
             System.out.println(e.toString());
         }
     }
        try {
            System.out.println(ArrayUtil.class.getDeclaredMethod("findMax", double[].class,int.class,int.class));
        } catch (Exception e1) {
        }
sc.close();
    }
}
